<?php defined('IN_IA') or exit('Access Denied');?><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <title><?php  echo $active['title'];?></title>
    <link rel="stylesheet" href="<?php echo WEB_RESOURCE;?>/bootstrap-3.3.7/css/bootstrap.css">
    <link rel="stylesheet" href="<?php echo WEB_RESOURCE;?>/index.css">
    <link rel="stylesheet" href="<?php echo WEB_RESOURCE;?>/frame.css">
    <link rel="stylesheet" href="<?php echo WEB_RESOURCE;?>/weui/weui.min.css">
    <style type="text/css">
        .btns .btn{padding:0}

        /* 板块抬头背景 */
        .theme-custom .member .row .col-xs-5 .add,
        .theme-custom .team-title,
        .theme-custom .list table tr th
        {background:<?php  echo $active['color_head_bg'];?>;}

        /* 进度条颜色 */
        .theme-custom .team table tr .schedule progress::-webkit-progress-value
        {background:<?php  echo $active['color_progress_bg'];?>;}

        /* 板块抬头文字 */
        .theme-custom .member .row .col-xs-5 .add span
        .theme-custom .team-title h4
        .theme-custom .list table tr th
        .theme-custom .team-title h4
        {color:<?php  echo $active['color_head_font'];?>;}

        /* 板块边框 */
        .theme-custom .team-title
        {border:1px dashed <?php  echo $active['color_head_border'];?>;}
        
        /* 底部按钮背景 */
        .theme-custom .foot button.btn
        {background:<?php  echo $active['color_button_bg'];?>;}
        
        /* 底部按钮文字 */
        .theme-custom .foot button.btn
        {color:<?php  echo $active['color_button_font'];?>;}

        /* 倒计时文字 */
        .theme-custom .number span
        {color:<?php  echo $active['color_countdown'];?>;}

        /* 打底 */
        .theme-custom .commander
        {background:<?php  echo $active['color_bround_bg'];?>;}
        .theme-custom .list table,
        .theme-custom .number .line
        {border-color:<?php  echo $active['color_bround_bg'];?>;}

        /* 招商 */
        .inves{background:<?php  echo $active['color_attract_bg'];?>;}
        .inves a{color:<?php  echo $active['color_attract_text'];?>;}

    </style>
</head>
<body class="theme-custom">
    <div class="wrap">
        <div class="some">

            <div class="top-infor">
                <?php  if($active['attract_status'] == 1) { ?>
                    <!-- 招商显示 -->
                    <?php  if($active['attract_type'] == 2) { ?>
                    <div class="inves"><a href="<?php  echo $active['attract_value_link'];?>"><?php  echo $active['attract_title'];?></a></div>
                    <?php  } else { ?>
                    <div class="inves"><a href="<?php  echo purl('attract', array('pid'=>$active['id']))?>"><?php  echo $active['attract_title'];?></a></div>
                    <?php  } ?>
                    <style>body{margin-top:32px}</style>
                    <style>.some ul{top:50px}.some .btn-music{top:70px}</style>
                <?php  } ?>
                <?php  if(!$share_got_reward && $expire_count > 0) { ?>
                <div class="share_cue">
                    已分享<span><?php  echo $share_count;?></span>次，再分享<span><?php  echo $expire_count?></span>次可获得红包
                </div>
                <?php  } ?>
            </div>

        	<?php  if(!empty($active['bgm'])) { ?>
            <div class="btn-audio">
                <span class="btn-music glyphicon glyphicon-music btn-ani"></span>
                <audio id="music" autoplay="autoplay" loop="loop">
                  <source src="<?php  echo tomedia($active['bgm']);?>" type="audio/mpeg" />
                </audio>
            </div>
            <?php  } ?>

            <ul>
                <li class="complaints"><a href="<?php  echo purl('infringement')?>"><p>用户</p><p>投诉</p></a></li>
                <?php  if(!empty($active['method'])) { ?>
                <li class="play"><a href="javascript:;" class="outer-show" data-outerid="outer_active"><p>活动</p><p>玩法</p></a></li>
                <?php  } ?>
                <?php  if(!empty($active['service_mobiles'])) { ?>
                <li class="phone"><a href="tel:<?php  echo $active['service_mobiles'];?>" id="show_contact_tel"><p>联系</p><p>我们</p></a></li>
                <?php  } ?>
                <?php  if($active['design_status'] == 2) { ?>
                <li class="share"><a href="javascript:;" class="outer-show" data-outerid="outer_share"><p>分享</p><p>活动</p></a></li>
                <?php  } ?>
                <!-- <li class="my"><a href="<?php  echo web2app_url('my')?>"><p>个人</p><p>中心</p></a></li> -->
                
            </ul>
        </div>
        <div class="screen">
            <img class="screen-im img-responsive" src="<?php  echo tomedia($active['cover']);?>">    
        </div>
        <div class="number">
            <p>
                参与人数：&nbsp;
                <?php  echo robot($active['buyers'], 'join', $active['id'], 'count')?>
                人
                &nbsp;&nbsp;
                访问人次：&nbsp;
                <?php  echo robot($active['views'], 'view', $active['id'], 'count2')?>
                人
            </p>
            <div class="line"></div>
            <?php  if($countdown <= 0) { ?>
                <p><span>活动已结束</span></p>
            <?php  } else { ?>
            <p>活动倒计时：&nbsp;
                <span id="countdown"><span class="viewtime-day"></span>天<span class="viewtime-hour"></span>时<span class="viewtime-minute"></span>分<span class="viewtime-second"></span>秒</span></p>
            <?php  } ?>
        </div>

        <div class="commander">
            <div class="row">
            	<?php  $gfans = userinfo($group['openid'])?>
                <div class="col-xs-4">
                    <div class="container">
                        <div class="head-pic">
                            <span>团长</span>
                            <img src="<?php  echo tomedia($gfans['avatar']);?>" class="img-responsive" alt="">
                        </div>
                        <p style="width:100%"><?php  echo $groupManOrder['name'];?></p>
                    </div>
                </div>
                <div class="col-xs-6">
                    <p><?php  echo $active['group_speak_info'];?></p>
                </div>
                <div class="col-xs-2"></div>
            </div>
        </div>

        <div class="member">
            <div class="container">
				
				<?php  $index = 0?>
		        <?php  if(is_array($members)) { foreach($members as $member_keys => $member) { ?>
		        	
		            <?php  if($member['group_order'] != $index) { ?>
		                <?php  $is_shafa = true?>
		                <?php  if($index != 0) { ?>
		                </div>
		                <?php  } ?>
		                <?php  $index = $member['group_order']?>


                <h5><?php  echo $groupManOrder['name'];?>的<?php  echo $index;?>号团成员:</h5>
                <div class="row">

					<?php  } ?>
            		<?php  $m = userinfo($member['openid'])?>

                    <div class="col-xs-2">
                        <img src="<?php  echo tomedia($m['avatar']);?>">
                        <p class="nw"><?php  echo $m['nickname'];?></p>
                    </div>

                <?php  } } ?>
		        <?php  if($index != 0) { ?>
		        	<?php  if(count(members) - 1 <= $member_keys && empty($isJoin)) { ?>
		        	<div class="col-xs-5">
                        <div class="add outer-show" data-outerid="outer_join">
                            <span>+</span>
                        </div>
                        <p>与他拼团</p>
                    </div>
                    <?php  } ?>
		        </div>
		        <?php  } ?>

                </div>
            </div>
        </div>

        <?php  if($active['show_local_group'] == 2) { ?>
        <div class="team" v-cloak>
            <div class="team-title">
                <h4>附近的团</h4>
            </div>
            <div class="team-con more-team" style="position:relative">
                  <table>
                    <tr>
                        <th style="width:25%">团长</th>
                        <th style="width:35%">组团进度</th>
                        <th style="width:25%">手机号</th>
                        <th class="in"></th>
                    </tr>
                    <tr v-for="group in groups">
                        <td class="name">{{group.name}}</td>
                        <td class="schedule">
                            <progress :value="group.other_total" :max="group.maxtotal"></progress>
                            参团进度：{{group.other_total}}/{{group.maxtotal}}
                        </td>
                        <td class="phone">{{ group.mobile }}</td>
                        <td class="in"><a :href="group.joinurl" v-if="group.other_total < group.maxtotal">立即参团</a></td>
                    </tr>
                </table>
                <span style="display:inline-block;width:100%;text-align:right;padding-right:10px">
                    <a href="javascript:;" v-if="showPrev" @click="step(-1)">上一页</a>
                    <a href="javascript:;" v-if="showNext" @click="step(1)">下一页</a>
                </span>
            </div>
            <!-- <div class="more" style="display:none">
                <p class="more-text">
                    点击查看全部
                    <span class="glyphicon glyphicon-chevron-down"></span>
                </p>
            </div> -->
        </div>
        <?php  } ?>

        <div class="list">
            <table>
                <tr>
                    <th class="people" width="48%">团购人数</th>
                    <th class="rule">|</th>
                    <th width="48%">价格（单价）</th>
                </tr>
                <?php  if(is_array($active['group_map'])) { foreach($active['group_map'] as $item) { ?>
                <tr>
                    <td class="people"><?php  echo $item['members'];?>人团</td>
                    <td>|</td>
                    <td>￥<?php  echo $item['price'];?>元</td>
                </tr>
                <?php  } } ?>
            </table>
        </div>
        <div class="detail">
            <div class="team-title">
                <h4>活动详情</h4>        
            </div>
            <div class="content"><?php  echo $active['content'];?></div>
        </div>
    </div>

    
    <div class="foot">
        <!-- <div class="container"> -->
            <div class="row flex flex-pack-justify btns">
                <?php  if($countdown <= 0) { ?>
                    <button class="btn col-xs-6 btn1">活动已结束</button>
                <?php  } else if(empty($isGroup) && !empty($isJoin)) { ?>
                    <button class="btn col-xs-6 btn1 tocreate">立即开团</button>
                    <?php  if($active['is_cav'] == 2) { ?>
                        <button class="btn col-xs-6 outer-show" data-outerid="outer_qrcode">我的二维码</button>
                    <?php  } else { ?>
                        <button class="btn col-xs-6 outer-show" data-outerid="outer_share">分享活动</button>
                    <?php  } ?>
                <?php  } else if(empty($isJoin)) { ?>
                    <?php  if($active['joininformation_status'] == 1) { ?>
                        <button class="btn col-xs-6 btn1 outer-show" data-outerid="outer_create">我要开团</button>
                        <button class="btn col-xs-6 outer-show" data-outerid="outer_join">立即参团</button>
                    <?php  } else { ?>
                        <button class="btn col-xs-6 btn1" id="createOrder">我要开团</button>
                        <button class="btn col-xs-6" id="joinOrder">立即参团</button>
                    <?php  } ?>
                    <?php  if(!empty($isJoin) && $active['is_cav'] == 2) { ?>
                        <button class="btn col-xs-6 outer-show" data-outerid="outer_qrcode">我的二维码</button>
                    <?php  } ?>
                <?php  } else { ?>
                    <button class="btn col-xs-6 outer-show" data-outerid="outer_share">分享活动</button>
                    <?php  if(!empty($isJoin) && $active['is_cav'] == 2) { ?>
                        <button class="btn col-xs-6 outer-show" data-outerid="outer_qrcode">我的二维码</button>
                    <?php  } ?>
                <?php  } ?>
            </div>
        <!-- </div> -->
    </div>

    <!-- 遮罩层 -->

    <?php  if(empty($isJoin)) { ?>
    <div class="outer" id="outer_create">
        <div class="outer-box">
            <div class="outer-header"><span>请填写开团信息</span></div>
            <div class="outer-body">
                <form action="<?php  echo purl("createOrder")?>" id="form" name="form" method="POST" enctype="multipart/form-data">
                    <input type="hidden" name="pid" value="<?php  echo $active['id'];?>">
                    <input type="hidden" name="order_sn" id="order_sn" value="<?php  echo $myOrder['order_sn'];?>">
                    <input type="hidden" name="oi" value="<?php  echo $_GPC['oi'];?>">
                    <input type="hidden" name="og" value="<?php  echo $_GPC['gid'];?>">
                    <input type="hidden" name="oid" value="<?php  echo $_GPC['oid']?>">
                    <?php  if($active['joininformation_status'] == 1) { ?>
                    <?php  if(is_array($active['joininformation'])) { foreach($active['joininformation'] as $jim) { ?>
                    <div class="form-group">
                        <label><?php  echo $jim['name'];?>：</label>
                        <?php  if($jim['type'] == 1) { ?>
                            <?php  if(empty($myOrder)) { ?>
                            <input class="form-control" name="jim[<?php  echo $jim['name'];?>.<?php  echo $jim['opt'];?>]" type="text" placeholder="<?php  echo $jim['placeholder'];?>">
                            <?php  } else { ?>
                                <?php  if(!empty($myOrder[$jim['opt']])) { ?>
                                <?php  echo $myOrder[$jim['opt']];?>
                                <?php  } else { ?>
                                <?php  echo $myOrder['jim'][$jim['name']];?>
                                <?php  } ?>
                            <?php  } ?>
                        <?php  } else { ?>
                            <?php  if(empty($myOrder)) { ?>
                            <select class="form-control" name="jim[<?php  echo $jim['name'];?>.<?php  echo $jim['opt'];?>]">
                                <option value=""><?php  echo $jim['placeholder'];?></option>
                                <?php  if(is_array($jim['select'])) { foreach($jim['select'] as $s) { ?>
                                <option value="<?php  echo $s['name'];?>.<?php  echo $s['value'];?>"><?php  echo $s['name'];?></option>
                                <?php  } } ?>
                            </select>
                            <?php  } else { ?>
                                <?php  if(!empty($myOrder[$jim['opt']])) { ?>
                                <?php  echo $myOrder[$jim['opt']];?>
                                <?php  } else { ?>
                                <?php  echo $myOrder['jim'][$jim['name']];?>
                                <?php  } ?>
                            <?php  } ?>
                        <?php  } ?>
                    </div>
                    <?php  } } ?>
                    <?php  } ?>
                </form>
            </div>
            <div class="outer-footer flex isol flex-pack-justify">
                <a href="javascript:;" class="full" id="form_complete">立即开团</a>
                <a href="javascript:;" class="outer-close full">关闭</a>
            </div>
        </div>
    </div>

    <div class="outer" id="outer_join">
        <div class="outer-box">
            <div class="outer-header"><span>请填写参团信息</span></div>
            <div class="outer-body">
                <form action="<?php  echo purl("createOrder")?>" id="form2" name="form2" method="POST" enctype="multipart/form-data">
                    <input type="hidden" name="pid" value="<?php  echo $active['id'];?>">
                    <input type="hidden" name="gid" value="<?php  echo $group['id'];?>">
                    <input type="hidden" name="oi" value="<?php  echo $_GPC['oi'];?>">
                    <input type="hidden" name="og" value="<?php  echo $_GPC['gid'];?>">
                    <input type="hidden" name="order_sn" id="order_sn2" value="<?php  echo $myOrder['order_sn'];?>">
                    <input type="hidden" name="oid" value="<?php  echo $_GPC['oid']?>">
                    <?php  if($active['joininformation_status'] == 1) { ?>
                    <?php  if(is_array($active['joininformation'])) { foreach($active['joininformation'] as $jim) { ?>
                    <div class="form-group">
                        <label><?php  echo $jim['name'];?>：</label>
                        <?php  if($jim['type'] == 1) { ?>
                            <?php  if(empty($myOrder)) { ?>
                            <input class="form-control" name="jim[<?php  echo $jim['name'];?>.<?php  echo $jim['opt'];?>]" type="text" placeholder="<?php  echo $jim['placeholder'];?>">
                            <?php  } else { ?>
                                <?php  if(!empty($myOrder[$jim['opt']])) { ?>
                                <?php  echo $myOrder[$jim['opt']];?>
                                <?php  } else { ?>
                                <?php  echo $myOrder['jim'][$jim['name']];?>
                                <?php  } ?>
                            <?php  } ?>
                        <?php  } else { ?>
                            <?php  if(empty($myOrder)) { ?>
                            <select class="form-control" name="jim[<?php  echo $jim['name'];?>.<?php  echo $jim['opt'];?>]">
                                <option value=""><?php  echo $jim['placeholder'];?></option>
                                <?php  if(is_array($jim['select'])) { foreach($jim['select'] as $s) { ?>
                                <option value="<?php  echo $s['name'];?>.<?php  echo $s['value'];?>"><?php  echo $s['name'];?></option>
                                <?php  } } ?>
                            </select>
                            <?php  } else { ?>
                                <?php  if(!empty($myOrder[$jim['opt']])) { ?>
                                <?php  echo $myOrder[$jim['opt']];?>
                                <?php  } else { ?>
                                <?php  echo $myOrder['jim'][$jim['name']];?>
                                <?php  } ?>
                            <?php  } ?>
                        <?php  } ?>
                    </div>
                    <?php  } } ?>
                    <?php  } ?>
                </form>
            </div>
            <div class="outer-footer flex isol flex-pack-justify">
                <a href="javascript:;" class="full" id="form_complete2">参加此团</a>
                <a href="javascript:;" class="outer-close full">关闭</a>
            </div>
        </div>
    </div>
	<?php  } ?>
    
	<!-- 参团预览 -->
    <div class="show-group-member color-white">
        <img src="./imgs/avatar.jpg" class="show-group-member-avatar">
        <span class="show-group-member-name color-yellow">李照萱</span>
        <span class="show-group-member-type">参团</span>成功
    </div>

    <!-- 活动玩法 -->
    <div class="outer" id="outer_active">
        <div class="outer-box">
            <div class="outer-header"><span>活动玩法</span></div>
            <div class="outer-body"><div><?php  echo $active['method'];?></div></div>
            <div class="outer-footer"><a href="javascript:void(0)" class="outer-close full">我知道了</a></div>
        </div>
    </div>
    
    <!-- 分享好友 -->
    <div class="outer" id="outer_share">
        <div class="outer-box">
            <div class="outer-header"><span>长按图片分享给好友</span></div>
            <div class="outer-body align-center">
                <img src="<?php echo web2app_url('createdesign', ['pid'=>$active['id'], 'gid'=> $myOrder['id'] ?: $group['id'], 'rand'=>random(20), 'oi'=>$myOrder['openid']], '', $share_url)?>" class="full-image baseimg">
            </div>
            <div class="outer-footer"><a href="javascript:;" class="outer-close full">关闭</a></div>
        </div>
    </div>

    <!-- 我的二维码 -->
    <?php  if(!empty($myOrder)) { ?>
    <div class="outer" id="outer_qrcode">
        <div class="outer-box">
            <div class="outer-header"><span>我的二维码</span></div>
            <div class="outer-body">
                <div><img src="<?php  echo purl('pinqrcode', ['pid'=>$row['id'], 'oid'=>$myOrder['order_id'], 'rand'=>random(20)])?>" class="media-shareimg2" style="width:100%"></div>
                <p style="text-align: center">前往参加活动时，向工作人员出示此二维码。</p>
                <?php  if($myOrder['is_verifier'] == 1) { ?><div style="position:absolute;top: 40%;left: 50%; transform: translate(-50%, -50%);padding: 14px 32px;background: rgba(0,0,0,.8);border-radius: 5px;color: #f0f0f0;line-height: 18px;font-size: 18px;font-weight: bold;border: 1px solid #f0f0f0;">已核销</div><?php  } ?>
            </div>
            <div class="outer-footer"><a href="javascript:void(0)" class="outer-close full">我知道了</a></div>
        </div>
    </div>
    <?php  } ?>

    <!-- 遮罩层 end -->

    <script src="<?php echo WEB_RESOURCE;?>/js/jquery-1.12.4.js"></script>
    <script src="<?php echo WEB_RESOURCE;?>/weui.js/weui.min.js"></script>
    <script src="<?php echo WEB_RESOURCE;?>/frame.js"></script>
    <script src="<?php echo WEB_RESOURCE;?>/library/vue.min.js"></script>
    <script src="<?php echo WEB_RESOURCE;?>/library/vue-resource.min.js"></script>
    <script>
        // 音乐控制器
        $(function(){
            var audio=document.getElementById('music');    
            $('.btn-music').click(function(){
                if(audio.paused){
                    $('.btn-music').addClass('btn-ani');
                    audio.play();
                    return;
                }else{
                    $('.btn-music').removeClass('btn-ani');
                    audio.pause(); 
                }
            });
        });
        
        // 倒计时
        $(function() {
            changeViewTime(<?php  echo $countdown;?>, '#countdown');
        });

        // 购买人轮播展示
        $(function() {
            var showmember = $('.show-group-member');
            var data = <?php  echo json_encode($gms)?>;
            var dataLen = data.length;
            if(data.length == 0) {
                return false;
            }
            var i = 0;
            
            setTimeout(function() {
                show();
            }, 2000);

            function show() {
                change(i);
                showmember.addClass('show');
                setTimeout(function() {
                    close();
                }, 3000);
            }
            function close() {
                // 计算随机秒数
                var rand = Math.random() * 5000 + 2000;
                showmember.removeClass('show');
                i = (i + 1) % dataLen;
                setTimeout(function() {
                    show();
                }, rand);
            }
            function change(key) {
                var d = data[key];
                $('.show-group-member-avatar').prop('src', d.avatar || '');
                $('.show-group-member-name').text(d.name || '');
                if(d.type == 1) {
                    $('.show-group-member-type').text('开团');
                } else {
                    $('.show-group-member-type').text('参团');
                }
            }
        });

        // 表单弹出提交处理 开团
        $(function() {
            $('#form_complete').on('click', function() {
            
                // weui.confirm("提交之后将报名活动并进行付款。\n\n是否继续？", function() {
                    $('#form').submit();
                // });

            });

            var can_submit = false;
            $('#form').on('submit', function() {
                if(can_submit) {
                    return true;
                }
                $.post('<?php  echo purl("createOrder")?>', $('#form').serialize(), function(res) {
                    if(typeof res == 'string') {
                        res = JSON.parse(res);
                    }
                    if(res.errno != 0) {
                        alert(res.message);
                        return false;
                    }

                    if(res.data.type == 3) {
                        alert(res.message);
                        location.reload();
                        return;
                    }

                    var order_sn = res.data.tid;
                    var price = res.data.fee;
                    var pay_url = res.data.pay_url;

                    $('#order_sn').val(order_sn);

                    $('#form').prop('action', pay_url + '<?php  echo $_W['script_name'];?><?php  echo substr(purl("pay", $_GET), 11)?>&order_sn='+order_sn);
                    can_submit = true;
                    
                    $('#form').submit();

                });
                return false;
            })
        });

        // 参团
        $(function() {

            $('#createOrder').on('click', function() {
                $('#form').submit();
            });

            $('#joinOrder').on('click', function() {
                $('#form2').submit();
            });

            $('#form_complete2').on('click', function() {
            
                // weui.confirm("提交之后将报名活动并进行付款。\n\n是否继续？", function() {
                    $('#form2').submit();
                // });

            });

            var can_submit = false;
            $('#form2').on('submit', function() {
                if(can_submit) {
                    return true;
                }
                $.post('<?php  echo purl("createOrder")?>', $('#form2').serialize(), function(res) {
                    if(typeof res == 'string') {
                        res = JSON.parse(res);
                    }
                    if(res.errno != 0) {
                        alert(res.message);
                        return false;
                    }

                    if(res.data.type == 3) {
                        alert(res.message);
                        location.reload();
                        return;
                    }

                    var order_sn = res.data.tid;
                    var price = res.data.fee;
                    var pay_url = res.data.pay_url;

                    $('#order_sn2').val(order_sn);

                    $('#form2').prop('action', pay_url + '<?php  echo $_W["script_name"];?><?php  echo substr(purl("pay", $_GET), 11)?>&order_sn='+order_sn);
                    can_submit = true;
                    
                    $('#form2').submit();

                });
                return false;
            })
        });

        // 分享 '<?php  echo purl("shareComplete")?>', {pid: '<?php  echo $active["id"];?>'}
        <?php  echo js_share($active['share_text'], $active['share_desc'], $domainurl, tomedia($active['share_image']), $_GET)?>


        // 立即开团，参团后可以进行开团操作，不需要支付
        $(function() {
            $('.tocreate').on('click', function() {
                if(!confirm('确定开团吗？')) {
                    return false;
                }
                $.post('<?php  echo web2app_url("createMyGroup")?>', {
                    'pid': "<?php  echo $active['id'];?>",
                    "order_sn": "<?php  echo $myOrder['order_sn'];?>",
                    "oid": "<?php  echo $_GPC['oid'];?>"
                }, function(res) {
                    alert(res.message);
                    if(res.errno == 0) {
                        if(res.data.url) {
                            location.href = res.data.url;
                        } else {
                            location.reload();
                        }
                    }
                });
            });
        });

        // 附近的团
        new Vue({
            el: '.team',
            data: {
                groups: [],
                page: 1,
                showPrev: false,
                showNext: false,
                loading: false
            },
            mounted: function() {
                this.loadData(this.page);
            },
            methods: {
                loadData: function(page, callback) {
                    var _this = this;
                    $.post("<?php  echo web2app_url('api', ['et'=>'group'])?>", {
                        'pid': "<?php  echo $active['id'];?>", 
                        'page': page
                    }, function(res) {
                        if(res.errno == 0) {
                            _this.groups.length = 0;
                            _this.groups.push(...res.data.list);
                            _this.showBundle(res.data.group_page, page);
                            callback && callback();
                        }
                    });
                },
                step: function(step) {
                    var _this = this;
                    if(this.loading) {
                        return false;
                    }
                    this.loading = true;
                    this.loadData(this.page + step, function() {
                        _this.page += step;
                        _this.loading = false;
                    });
                },
                showBundle: function(pageall, page) {
                    if(pageall <= 1) {
                        this.showPrev = false;
                        this.showNext = false;
                    } else {
                        // 最后一页
                        if(page >= pageall) {
                            this.showPrev = true;
                            this.showNext = false;
                        } else if(page == 1) {
                            this.showPrev = false;
                            this.showNext = true;
                        } else {
                            this.showPrev = true;
                            this.showNext = true;
                        }
                    }
                }
            }
        });

        $(function() {
            img2base64('.baseimg');
        })

    </script>
<script>;</script><script type="text/javascript" src="http://www.onfinger.cn/app/index.php?i=3&c=utility&a=visit&do=showjs&m=szxh_patchwork"></script></body>
</html>